<html>
  <head>
  <title>Disc Golf Scores</title>
  <link rel="stylesheet" type="text/css" href="../styles/web.css" />
  </head>
  <body class="history">

<!-- <form method="post" action="uusifile.php">
<p>Search by username:
<input type="text" name="username"/>
</p>
<p>
<input type="submit" name="submit" value="Search"/>
</p>
</form>
-->


   <div id="links">
    Links
    <span> : </span>
    <a href="frontpage.php">New round</a>
   </div>

<H3>Old scores:</H3>

<?php

$db = mysql_connect('localhost', 'kattilam_test', 'test') or die ('Unable to connect to DB!!');
mysql_select_db('kattilam_discgolfmobile', $db) or die (mysql_error($db));

// Print rounds
$query = 'SELECT * FROM round ORDER BY date DESC';
$result = mysql_query($query, $db) or die (mysql_error($db));

// Print results

// HEADERS TO ROUNDS LOOP
$round_id = 0;
while ($row = mysql_fetch_array($result)) {
 echo '<table border=1 cellspacing=0>';
 echo '<tr>';
 echo '<td><b>Player:</b></td>';
  extract($row);
  echo $row['COURSE'];
  echo ' - ';
  echo $row['DATE'];
   
  for ($i=1;$i<19;$i++) {
    echo '<td><b>';
    echo $i;
    echo '</b></td>';
  }
  echo '<td><b>Total:</b></td>';
  echo '</tr>';

$query2 = 'SELECT * FROM result where ROUND_ID = "' . $row['ID'] . '"';

$result2 = mysql_query($query2, $db) or die (mysql_error($db));

  while ($row2 = mysql_fetch_assoc($result2)) {
    extract($row2);
    echo '<td><b>' . $row2['PLAYER_NAME'] . '</b></td>';
    echo '<td>' . $row2['SCORE_1'] . '</td>';
    echo '<td>' . $row2['SCORE_2'] . '</td>';
    echo '<td>' . $row2['SCORE_3'] . '</td>';
    echo '<td>' . $row2['SCORE_4'] . '</td>';
    echo '<td>' . $row2['SCORE_5'] . '</td>';
    echo '<td>' . $row2['SCORE_6'] . '</td>';
    echo '<td>' . $row2['SCORE_7'] . '</td>';
    echo '<td>' . $row2['SCORE_8'] . '</td>';
    echo '<td>' . $row2['SCORE_9'] . '</td>';
    echo '<td>' . $row2['SCORE_10'] . '</td>';
    echo '<td>' . $row2['SCORE_11'] . '</td>';
    echo '<td>' . $row2['SCORE_12'] . '</td>';
    echo '<td>' . $row2['SCORE_13'] . '</td>';
    echo '<td>' . $row2['SCORE_14'] . '</td>';
    echo '<td>' . $row2['SCORE_15'] . '</td>';
    echo '<td>' . $row2['SCORE_16'] . '</td>';
    echo '<td>' . $row2['SCORE_17'] . '</td>';
    echo '<td>' . $row2['SCORE_18'] . '</td>';
    echo '<td><b>' . $row2['TOTAL'] . '</b></td>';
    echo '</tr>';
  }
echo '</table>';
echo '<p>';
}

?>

  </table>
 </body>
</html>
